<?php
// +----------------------------------------------------------------------
// | 中犇单商户
// +----------------------------------------------------------------------
// | Copyright (c) 2019-2021 中犇科技 All rights reserved.
// +----------------------------------------------------------------------

namespace app\user\export;

use app\common\traits\controller\Export;
use app\user\model\MoneyLog;

class MoneylogExport
{
    use Export;
    /**
     * 会员主表列表
     * @author 似水星辰 [2630481389@qq.com]
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function export($map)
    {
        // 数据列表
        $list = MoneyLog::getAllList($map, [], false);
        $excelData = $_excelData = [];
        foreach ($list as $v) {
            $excelData[] = [
                'user_nickname' => $v['user_nickname'],
                'before_money' => $v['before_money'],
                'change_money' => $v['change_money'],
                'after_money' => $v['after_money'],
                'change_type' => $v['change_type'],
                'create_time' => $v['create_time'],
                'remark' => $v['remark'],
            ];
        }
        $_excelData[0]['list'] = $excelData;
        $xlsName = lang('会员余额变更记录').'-' . date("Y-m-d H:i:s", time());
        $xlsCell = [
            ['user_nickname', lang('会员名称')],
            ['before_money', lang('变动前金额')],
            ['change_money', lang('变动金额')],
            ['after_money', lang('变动后金额')],
            ['change_type', lang('类型')],
            ['create_time', lang('变动时间')],
            ['remark', lang('备注')],
        ];
        $excelData = array_values($_excelData);
        $this->exportExcel($xlsName, $xlsCell, $excelData);
    }
}
